package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MesChkbillCgzx;
import com.ruoyi.system.service.IMesChkbillCgzxService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 城轨轴箱自检任务 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-22
 */
@Controller
@RequestMapping("/system/mesChkbillCgzx")
public class MesChkbillCgzxController extends BaseController
{
    private String prefix = "system/mesChkbillCgzx";
	
	@Autowired
	private IMesChkbillCgzxService mesChkbillCgzxService;
	
	@RequiresPermissions("system:mesChkbillCgzx:view")
	@GetMapping()
	public String mesChkbillCgzx()
	{
	    return prefix + "/mesChkbillCgzx";
	}
	
	/**
	 * 查询城轨轴箱自检任务列表
	 */
	@RequiresPermissions("system:mesChkbillCgzx:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(MesChkbillCgzx mesChkbillCgzx)
	{
		startPage();
        List<MesChkbillCgzx> list = mesChkbillCgzxService.selectMesChkbillCgzxList(mesChkbillCgzx);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出城轨轴箱自检任务列表
	 */
	@RequiresPermissions("system:mesChkbillCgzx:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MesChkbillCgzx mesChkbillCgzx)
    {
    	List<MesChkbillCgzx> list = mesChkbillCgzxService.selectMesChkbillCgzxList(mesChkbillCgzx);
        ExcelUtil<MesChkbillCgzx> util = new ExcelUtil<MesChkbillCgzx>(MesChkbillCgzx.class);
        return util.exportExcel(list, "mesChkbillCgzx");
    }
	
	/**
	 * 新增城轨轴箱自检任务
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存城轨轴箱自检任务
	 */
	@RequiresPermissions("system:mesChkbillCgzx:add")
	@Log(title = "城轨轴箱自检任务", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(MesChkbillCgzx mesChkbillCgzx)
	{		
		return toAjax(mesChkbillCgzxService.insertMesChkbillCgzx(mesChkbillCgzx));
	}

	/**
	 * 修改城轨轴箱自检任务
	 */
	@GetMapping("/edit/{gid}")
	public String edit(@PathVariable("gid") String gid, ModelMap mmap)
	{
		MesChkbillCgzx mesChkbillCgzx = mesChkbillCgzxService.selectMesChkbillCgzxById(gid);
		mmap.put("mesChkbillCgzx", mesChkbillCgzx);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存城轨轴箱自检任务
	 */
	@RequiresPermissions("system:mesChkbillCgzx:edit")
	@Log(title = "城轨轴箱自检任务", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(MesChkbillCgzx mesChkbillCgzx)
	{		
		return toAjax(mesChkbillCgzxService.updateMesChkbillCgzx(mesChkbillCgzx));
	}
	
	/**
	 * 删除城轨轴箱自检任务
	 */
	@RequiresPermissions("system:mesChkbillCgzx:remove")
	@Log(title = "城轨轴箱自检任务", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(mesChkbillCgzxService.deleteMesChkbillCgzxByIds(ids));
	}
	
}
